package com.niiwoo.civet.trade.enums.kaola;

import com.niiwoo.tripod.provider.exception.NoSuchEnumValueException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum KaolaRepayOrderRepayStatusEnum {

    UN_DEAL( (byte)0,"待处理"),
    WITH_HOLDING( (byte)1,"代扣中"),
    REPAYING( (byte)2,"还款中"),
    REPAY_SUCCESS( (byte)3,"还款成功"),
    REPAY_FAIL( (byte)4,"还款失败"),
    ;


    private Byte value;

    private String desc;

    public static KaolaRepayOrderRepayStatusEnum enumOf(Byte code) {
        return Arrays.stream(values())
                .filter(v -> v.getValue().equals(code))
                .findFirst()
                .orElseThrow(() -> new NoSuchEnumValueException(String.valueOf(code)));
    }

}
